package com.zhinong.listener;

import com.zhinong.service.EmployeeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class EmployeeListener {

    private final EmployeeService employeeService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "employeedead.queue",durable = "true"),
            exchange = @Exchange(name = "employeedead.direct",delayed = "true"),
            key = "employeedead.success"
    ))
    public void listener(Long id){
        log.info("监听到消息");
        employeeService.deleteById(id);
    }
}
